Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Jul 6, 2025

Refactor CustomQueryHotkeySetting control to style as CustomShortcutSetting

Seperate from #3770. This refactor is helpful for hotkey model change in #3770.

Test

  • Add / Edit / Remove custom query hotkey

@prlabeler prlabeler bot added Code Refactor enhancement New feature or request labels Jul 6, 2025
@Jack251970 Jack251970 requested a review from Copilot July 6, 2025 13:16
Copy link

gitstream-cm bot commented Jul 6, 2025

🥷 Code experts: onesounds, Yusyuriv

Jack251970, onesounds have most 👩‍💻 activity in the files.
Jack251970, onesounds have most 🧠 knowledge in the files.

See details

Flow.Launcher.Infrastructure/UserSettings/PluginHotkey.cs

Activity based on git-commit:

Jack251970 onesounds
JUL
JUN
MAY
APR
MAR
FEB

Knowledge based on git-blame:

Flow.Launcher/CustomQueryHotkeySetting.xaml

Activity based on git-commit:

Jack251970 onesounds
JUL
JUN
MAY
APR 1 additions & 1 deletions 1 additions & 1 deletions
MAR 14 additions & 14 deletions
FEB 1 additions & 4 deletions

Knowledge based on git-blame:
onesounds: 51%
Jack251970: 9%

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
JUL
JUN
MAY
APR 19 additions & 39 deletions 20 additions & 1 deletions
MAR
FEB 15 additions & 15 deletions

Knowledge based on git-blame:
Jack251970: 32%
onesounds: 14%

Flow.Launcher/CustomShortcutSetting.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
JUL
JUN
MAY
APR 13 additions & 37 deletions 22 additions & 1 deletions
MAR
FEB 8 additions & 9 deletions

Knowledge based on git-blame:
Jack251970: 12%

Flow.Launcher/Languages/en.xaml

Activity based on git-commit:

Jack251970 onesounds
JUL
JUN 8 additions & 0 deletions 7 additions & 6 deletions
MAY 14 additions & 3 deletions 15 additions & 2 deletions
APR 22 additions & 21 deletions 45 additions & 23 deletions
MAR 67 additions & 42 deletions 8 additions & 3 deletions
FEB 15 additions & 9 deletions

Knowledge based on git-blame:
onesounds: 43%
Jack251970: 12%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs

Activity based on git-commit:

Jack251970 onesounds
JUL
JUN
MAY
APR 8 additions & 9 deletions
MAR
FEB

Knowledge based on git-blame:
Jack251970: 10%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

Copy link

gitstream-cm bot commented Jul 6, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

@Jack251970 Jack251970 removed the enhancement New feature or request label Jul 6, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the CustomQueryHotkeySetting control to match the styling and behavior of CustomShortcutSetting, centralizes validation and dialog flow, and updates the underlying model and localization.

  • Reworked SettingsPaneHotkeyViewModel to use new constructors, handle dialog results, and update hotkeys via HotKeyMapper
  • Refactored CustomQueryHotkeySetting window class: unified add/update constructors, replaced inline update logic, and exposed Hotkey/ActionKeyword as bindable properties
  • Added equality overrides in CustomPluginHotkey model and extended localization keys for empty/invalid states

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs Swapped old dialog calls for new constructors and result handling
Flow.Launcher/Languages/en.xaml Updated “invalidPluginHotkey”, added emptyPluginHotkey and invalidShortcut strings
Flow.Launcher/CustomQueryHotkeySetting.xaml.cs Major overhaul of add/update logic, validation, and public properties
Flow.Launcher/CustomQueryHotkeySetting.xaml Adjusted bindings and button visuals for add/update modes
Flow.Launcher.Infrastructure/UserSettings/PluginHotkey.cs Renamed model to CustomPluginHotkey, added ctor, Equals/GetHashCode
Comments suppressed due to low confidence (2)

Flow.Launcher.Infrastructure/UserSettings/PluginHotkey.cs:1

  • The file name PluginHotkey.cs does not match the class name CustomPluginHotkey. Consider renaming the file to CustomPluginHotkey.cs for consistency.
using System;

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs:40

  • [nitpick] Consider adding a check here to prevent assigning a hotkey that already exists in Settings.CustomPluginHotkeys, similar to the duplicate shortcut check in CustomShortcutSetting.
            Hotkey = HotkeyControl.CurrentHotkey.ToString();

@Jack251970
Copy link
Member Author

@coderabbitai full review

Copy link
Contributor

coderabbitai bot commented Jul 6, 2025

✅ Actions performed

Full review triggered.

Copy link
Contributor

coderabbitai bot commented Jul 6, 2025

📝 Walkthrough

"""

Walkthrough

The changes refactor the management of custom plugin hotkeys and shortcuts by moving responsibility for collection updates and hotkey registration from the UI dialog to the view model. New validation logic ensures hotkeys and shortcuts exist before editing, and error messages are improved. UI elements and localization strings are updated to support these changes.

Changes

File(s) Change Summary
Flow.Launcher.Infrastructure/UserSettings/PluginHotkey.cs Added constructor, Equals, and GetHashCode overrides to CustomPluginHotkey.
Flow.Launcher/CustomQueryHotkeySetting.xaml, Flow.Launcher/CustomQueryHotkeySetting.xaml.cs Refactored dialog: exposes hotkey/action properties, removes direct settings manipulation, updates UI for add/update modes.
Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs Enhanced validation and explicit update flows for editing/adding custom hotkeys and shortcuts.
Flow.Launcher/Languages/en.xaml Updated and added resource strings for hotkey/shortcut validation messages.
Flow.Launcher/CustomShortcutSetting.xaml.cs Minor formatting change (added blank lines); no logic change.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingsPaneHotkeyViewModel
    participant CustomQueryHotkeySetting
    participant Settings
    participant HotkeyMapper

    User->>SettingsPaneHotkeyViewModel: Initiate Add/Edit Custom Hotkey
    SettingsPaneHotkeyViewModel->>CustomQueryHotkeySetting: Open dialog (with or without existing hotkey)
    CustomQueryHotkeySetting->>User: User enters hotkey and action keyword
    User->>CustomQueryHotkeySetting: Confirm (OK)
    CustomQueryHotkeySetting->>SettingsPaneHotkeyViewModel: Return Hotkey and ActionKeyword
    SettingsPaneHotkeyViewModel->>Settings: Validate and update hotkey collection
    SettingsPaneHotkeyViewModel->>HotkeyMapper: Register/Unregister hotkey as needed
Loading

Suggested labels

enhancement

Suggested reviewers

  • jjw24
  • onesounds
    """

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e36d5d8 and 4d5a8cc.

📒 Files selected for processing (1)
  • Flow.Launcher/Languages/en.xaml (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher/Languages/en.xaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: Check Spelling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fcc12d and eb2b8d0.

📒 Files selected for processing (6)
  • Flow.Launcher.Infrastructure/UserSettings/PluginHotkey.cs (1 hunks)
  • Flow.Launcher/CustomQueryHotkeySetting.xaml (2 hunks)
  • Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (2 hunks)
  • Flow.Launcher/CustomShortcutSetting.xaml.cs (1 hunks)
  • Flow.Launcher/Languages/en.xaml (2 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (2 hunks)
🧰 Additional context used
🧠 Learnings (6)
Flow.Launcher/CustomShortcutSetting.xaml.cs (4)
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3672
File: Flow.Launcher/MainWindow.xaml.cs:244-247
Timestamp: 2025-06-08T14:12:21.348Z
Learning: In Flow.Launcher, App.NotifyIcon is created before MainWindow creation, so null checks for App.NotifyIcon are not necessary when accessing it from MainWindow code.
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3057
File: Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs:0-0
Timestamp: 2024-11-03T07:40:11.014Z
Learning: In Flow Launcher, when using Windows Forms dialogs (e.g., in `JsonRPCPluginSettings.cs`), path validation is enabled by default in `OpenFileDialog` and `FolderBrowserDialog`, preventing users from selecting invalid paths, but it's possible to opt out of this validation on individual dialogs.
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:12:13.386Z
Learning: In Flow.Launcher, hotkey styling is implemented with a two-component structure: a Border element with style `ItemHotkeyBGStyle` that provides background and border styling, containing a TextBlock with style `ItemHotkeyStyle` that handles the text styling.
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3672
File: Flow.Launcher/MainWindow.xaml.cs:318-318
Timestamp: 2025-06-08T14:12:12.842Z
Learning: In Flow.Launcher, the App.NotifyIcon static property is initialized in the App class before MainWindow creation, so null checks are not needed when accessing App.NotifyIcon in MainWindow lifecycle methods.
Flow.Launcher/Languages/en.xaml (2)
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:12:13.386Z
Learning: In Flow.Launcher, hotkey styling is implemented with a two-component structure: a Border element with style `ItemHotkeyBGStyle` that provides background and border styling, containing a TextBlock with style `ItemHotkeyStyle` that handles the text styling.
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3057
File: Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs:0-0
Timestamp: 2024-11-03T07:40:11.014Z
Learning: In Flow Launcher, when using Windows Forms dialogs (e.g., in `JsonRPCPluginSettings.cs`), path validation is enabled by default in `OpenFileDialog` and `FolderBrowserDialog`, preventing users from selecting invalid paths, but it's possible to opt out of this validation on individual dialogs.
Flow.Launcher.Infrastructure/UserSettings/PluginHotkey.cs (4)
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3791
File: Flow.Launcher.Core/Plugin/PluginManager.cs:293-295
Timestamp: 2025-07-01T05:46:13.251Z
Learning: In Flow.Launcher.Core/Plugin/PluginManager.cs, when checking if a plugin is modified within the PluginManager class itself, prefer using the internal static PluginModified(string id) method directly rather than going through API.PluginModified() for better performance and architectural design.
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:12:13.386Z
Learning: In Flow.Launcher, hotkey styling is implemented with a two-component structure: a Border element with style `ItemHotkeyBGStyle` that provides background and border styling, containing a TextBlock with style `ItemHotkeyStyle` that handles the text styling.
Learnt from: jjw24
PR: Flow-Launcher/Flow.Launcher#2448
File: Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs:16-20
Timestamp: 2025-01-18T10:10:18.414Z
Learning: In Flow Launcher's plugin system, the PluginInitContext parameter passed to plugin constructors is guaranteed to be non-null by the plugin initialization system, making null checks unnecessary.
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3057
File: Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs:0-0
Timestamp: 2024-11-03T07:40:11.014Z
Learning: In Flow Launcher, when using Windows Forms dialogs (e.g., in `JsonRPCPluginSettings.cs`), path validation is enabled by default in `OpenFileDialog` and `FolderBrowserDialog`, preventing users from selecting invalid paths, but it's possible to opt out of this validation on individual dialogs.
Flow.Launcher/CustomQueryHotkeySetting.xaml (4)
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:12:13.386Z
Learning: In Flow.Launcher, hotkey styling is implemented with a two-component structure: a Border element with style `ItemHotkeyBGStyle` that provides background and border styling, containing a TextBlock with style `ItemHotkeyStyle` that handles the text styling.
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:20:54.978Z
Learning: In WPF applications like Flow.Launcher, Border elements cannot directly display text content and require a child element like TextBlock to handle text rendering. This separation of concerns (Border for visual container styling, TextBlock for text display) follows WPF best practices and provides greater styling flexibility.
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:20:54.978Z
Learning: In WPF applications like Flow.Launcher, Border elements cannot directly display text content and require a child element like TextBlock to handle text rendering. This separation of concerns (Border for visual container styling, TextBlock for text display) follows WPF best practices and provides greater styling flexibility.
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#0
File: :0-0
Timestamp: 2025-04-23T15:14:49.986Z
Learning: In WPF applications like Flow.Launcher, font styling should be applied using implicit styles instead of setting the FontFamily property on individual controls. Define implicit styles in a ResourceDictionary using <Style TargetType="{x:Type Button}"> format and merge it into App.xaml, which automatically applies the font to all instances of the control type while still allowing explicit overrides where needed.
Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (2)
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:12:13.386Z
Learning: In Flow.Launcher, hotkey styling is implemented with a two-component structure: a Border element with style `ItemHotkeyBGStyle` that provides background and border styling, containing a TextBlock with style `ItemHotkeyStyle` that handles the text styling.
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3057
File: Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs:0-0
Timestamp: 2024-11-03T07:40:11.014Z
Learning: In Flow Launcher, when using Windows Forms dialogs (e.g., in `JsonRPCPluginSettings.cs`), path validation is enabled by default in `OpenFileDialog` and `FolderBrowserDialog`, preventing users from selecting invalid paths, but it's possible to opt out of this validation on individual dialogs.
Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (3)
Learnt from: onesounds
PR: Flow-Launcher/Flow.Launcher#3394
File: Flow.Launcher/Themes/Darker Glass.xaml:134-141
Timestamp: 2025-03-28T21:12:13.386Z
Learning: In Flow.Launcher, hotkey styling is implemented with a two-component structure: a Border element with style `ItemHotkeyBGStyle` that provides background and border styling, containing a TextBlock with style `ItemHotkeyStyle` that handles the text styling.
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3791
File: Flow.Launcher.Core/Plugin/PluginManager.cs:293-295
Timestamp: 2025-07-01T05:46:13.251Z
Learning: In Flow.Launcher.Core/Plugin/PluginManager.cs, when checking if a plugin is modified within the PluginManager class itself, prefer using the internal static PluginModified(string id) method directly rather than going through API.PluginModified() for better performance and architectural design.
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3057
File: Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs:0-0
Timestamp: 2024-11-03T07:40:11.014Z
Learning: In Flow Launcher, when using Windows Forms dialogs (e.g., in `JsonRPCPluginSettings.cs`), path validation is enabled by default in `OpenFileDialog` and `FolderBrowserDialog`, preventing users from selecting invalid paths, but it's possible to opt out of this validation on individual dialogs.
🪛 GitHub Check: Check Spelling
Flow.Launcher/CustomQueryHotkeySetting.xaml

[warning] 162-162:
lbl is not a recognized word. (unrecognized-spelling)

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

[warning] 28-28:
lbl is not a recognized word. (unrecognized-spelling)


[warning] 19-19:
lbl is not a recognized word. (unrecognized-spelling)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (14)
Flow.Launcher/CustomShortcutSetting.xaml.cs (1)

46-46: LGTM! Code readability improved.

The added blank lines around conditional validation blocks improve code readability and follow good formatting practices.

Also applies to: 53-53

Flow.Launcher/CustomQueryHotkeySetting.xaml (2)

123-123: LGTM! Data binding properly implemented.

The two-way data binding for ActionKeyword enables proper communication between the UI and the dialog's data properties.


154-167: LGTM! Dynamic button labels implemented correctly.

The Grid structure with collapsed TextBlocks allows for runtime toggling between "done" and "update" labels, supporting both add and edit modes. This approach follows WPF best practices for conditional UI display.

Note: The static analysis warning about "lbl" is a false positive - "lbl" is a standard abbreviation for "label" in UI control naming conventions.

Flow.Launcher/Languages/en.xaml (1)

432-432: LGTM! Improved error messages for better user experience.

The localization updates provide more concise and consistent error messages:

  • "Hotkey is invalid" is more direct than "Invalid plugin hotkey"
  • New validation messages for empty hotkeys and invalid shortcuts support enhanced validation

These changes align well with the improved validation logic implemented elsewhere in the PR.

Also applies to: 439-439, 448-448

Flow.Launcher.Infrastructure/UserSettings/PluginHotkey.cs (3)

1-1: LGTM! Necessary namespace added.

The System namespace is required for the HashCode.Combine method used in the GetHashCode override.


11-15: LGTM! Constructor properly implemented.

The constructor provides a convenient way to create instances with both required properties initialized, supporting the refactored dialog workflow.


17-30: LGTM! Value equality correctly implemented.

The Equals and GetHashCode overrides follow .NET best practices:

  • Proper type checking with pattern matching
  • Comparison of both key properties (Hotkey and ActionKeyword)
  • Use of HashCode.Combine for proper hash code generation

This enables the class to work correctly in collections and supports the validation logic in the view model.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (3)

72-86: Excellent validation and explicit hotkey management.

The enhanced CustomHotkeyEdit method introduces important improvements:

  • Validates hotkey existence before editing to prevent stale reference issues
  • Creates new instances instead of modifying existing ones (immutable approach)
  • Explicitly manages hotkey registration/removal in the HotKeyMapper
  • Leverages the new equality implementation in CustomPluginHotkey

This approach is more robust and prevents potential synchronization issues between the UI and the hotkey system.


92-98: LGTM! Simplified and improved hotkey addition.

The refactored CustomHotkeyAdd method is cleaner and more explicit:

  • Single dialog call with conditional handling
  • Creates new hotkey instance using the constructor
  • Explicitly registers the hotkey with HotKeyMapper

This centralizes hotkey management in the view model rather than the dialog, which is a better architectural approach.


135-146: LGTM! Consistent validation pattern for shortcuts.

The CustomShortcutEdit method now follows the same validation pattern as hotkeys:

  • Validates shortcut existence before editing
  • Uses the found item for replacement to ensure accuracy
  • Provides appropriate error feedback using the new localization strings

This creates consistency across the hotkey and shortcut management workflows.

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (4)

1-11: Good architectural improvement with the new public properties.

The refactoring to expose Hotkey and ActionKeyword as public properties aligns well with the separation of concerns principle, allowing the dialog to focus solely on data collection rather than settings management.


32-36: LGTM - Cancel handler is correctly implemented.

The explicit setting of DialogResult = false before closing ensures the calling code can properly detect cancellation.


38-50: The validation and dialog result logic is correct but complex.

The validation logic correctly allows either hotkey or action keyword to be set (or both), and the dialog result logic properly handles both add and update scenarios by detecting changes.

The DialogResult logic !update || originalCustomHotkey.Hotkey != Hotkey || originalCustomHotkey.ActionKeyword != ActionKeyword correctly:

  • Returns true for new hotkeys (add mode)
  • Returns true for updates with changes
  • Returns false for updates with no changes

This allows the calling view model to determine if settings need to be updated.


59-63: LGTM - Escape handler is consistent with cancel behavior.

The escape key handler correctly mirrors the cancel button behavior by setting DialogResult = false.

@coderabbitai coderabbitai bot added the enhancement New feature or request label Jul 6, 2025
@Jack251970 Jack251970 removed the enhancement New feature or request label Jul 6, 2025
@Jack251970 Jack251970 added this to the 2.0.0 milestone Jul 6, 2025
@coderabbitai coderabbitai bot added the enhancement New feature or request label Jul 10, 2025
@Jack251970
Copy link
Member Author

These two spelling warning cannot be fixed since they are key of the string resources. Other spelling warnings are all handled.

image

@jjw24 jjw24 merged commit 48d0898 into dev Jul 10, 2025
6 checks passed
@jjw24 jjw24 deleted the CustomQueryHotkeySetting_refactor branch July 10, 2025 11:45
@jjw24 jjw24 added bug Something isn't working and removed enhancement New feature or request labels Jul 10, 2025
@jjw24 jjw24 modified the milestones: 2.0.0, 1.20.2 Jul 13, 2025
jjw24 added a commit that referenced this pull request Jul 13, 2025
…refactor

Refactor CustomQueryHotkeySetting control
TBM13 pushed a commit to TBM13/Flow.Launcher that referenced this pull request Jul 14, 2025
…otkeySetting_refactor

Refactor CustomQueryHotkeySetting control
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Code Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants